<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>子账号管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/member/member_list.css">
    <%@include file="../../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/member/group/childList.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <input type="hidden" name="partnerId" value="${partnerId}"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">昵称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="realname" autocomplete="off" class="layui-input"
                                           value="${member.realname}" placeholder="请输入查询昵称">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">&nbsp;&nbsp;账号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="username" autocomplete="off" class="layui-input"
                                           value="${member.username}" placeholder="请输入查询账号">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="mobile" autocomplete="off" class="layui-input"
                                           value="${member.mobile}" placeholder="请输入查询联系电话">
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">注册时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table" lay-size="sm">
                        <colgroup>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col  width="26%">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>昵称</th>
                            <th>账号</th>
                            <th>职位</th>
                            <th>电话</th>
                            <th>注册时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="member" items="${members}" varStatus="varStatus">
                            <tr>
                                <td class="table-member">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${member.logo != null}">${member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                 alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">
                                            <a class="blue" title="${member.realname}"
                                               href="javascript:void(0);">${member.realname}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>${member.username}</td>
                                <td>${member.jobTitle}</td>
                                <td>${member.mobile}</td>
                                <td><fmt:formatDate value="${member.createDate}" pattern="yyyy-MM-dd HH:mm"/></td>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a href="${ctx}/member/group/childForm.do?id=${member.id}&from=manager"
                                           target="_self">
                                            编辑
                                        </a>
                                        <c:if test="${(!isChild ||isXzgsAdmin)&& partnerId ==null}">
                                            <a href="${ctx}/member/group/childList.do?partnerId=${member.id}&from=manager"
                                               target="_self">
                                                子账号列表
                                            </a>
                                        </c:if>
                                        <c:if test="${partnerId !=null}">
                                            <a target="_self"
                                               href="javascript:openDialog('分配角色-${member.realname}','${ctx}/system/role/distributionRole.do?memberId=${member.id}&identity=partner&isNew=true&partnerId=${partnerId}&typeId=2','700px','500px')">
                                                分配角色
                                            </a>
                                            <a target="_self"
                                               href="javascript:openDialog('分配数据-${member.realname}','${ctx}/memberGroup/Permission/toSetPermission.do?memberId=${member.id}&partnerId=${partnerId}','675px','560px')">
                                                分配数据
                                            </a>
                                        </c:if>
                                        <c:if test="${(!isChild ||isXzgsAdmin)&& partnerId ==null}">
                                            <a target="_self"
                                               href="javascript:openDialog('分配角色-${member.realname}','${ctx}/system/role/distributionRole.do?memberId=${member.id}&identity=partner&isNew=true&partnerId=${xzgsId}&typeId=1','700px','500px')">
                                                分配角色
                                            </a>
                                            <a class="qr-btn" href="javascript:txz.openQrDialog({
															title:'扫码二维码可预览分享',
															detailList:[{
																title:'分社邀请二维码',
																url:'${member.childInviteQrCode}'
															}]
														})"><i class="iconfont icon-qrcode btn-icon"></i> 二维码</a>
                                        </c:if>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>

<script type="text/javascript">
    $(function () {

        // 加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        var layer;
        layui.use(['laydate', 'layer'], function () {
            var laydate = layui.laydate;
            layer = layui.layer;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    function openDialog(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }
</script>
<script type="text/javascript">
    var memberGroupId = '${memberGroupId}';
    if(${isXzgsAdmin}){
        memberGroupId = '${xzgsId}';
    }
    if(${partnerId!=null}){
        memberGroupId = '${partnerId}';
    }
    txz.initHeader({
        nav: [{
            name: '子账号管理',
            curr: true
        }],
        info: '<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        <c:if test="${partnerId!=null ||(!isChild ||isXzgsAdmin)}">
        btns: [{
            name: '添加子账号',
            href: '${ctx}/member/group/childForm.do?partnerId='+memberGroupId+'&from=manager',
            icon: 'add',
            isCheckExpire: true
        }]
        </c:if>
    });
</script>
</body>
</html>